//
//  SupplyOfGoodsViewController.m
//  XYMaterial
//
//  Created by 肖扬 on 15/12/9.
//  Copyright © 2015年 肖扬. All rights reserved.
//

#import "SupplyOfGoodsViewController.h"
#import "BoardViewController.h"
@interface SupplyOfGoodsViewController ()

@end

@implementation SupplyOfGoodsViewController
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[appStatus shareAppStatus].tabBarController showTabbar];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.leftBtn setHidden:YES];
    self.title = @"货源";
    NSArray *imgArray = [NSArray arrayWithObjects:@"板材",@"门板",@"装饰纸", nil];
    for (int i = 0; i < [imgArray count]; i++) {
        UIButton *button = [self createButtonImg:CGRectMake(10, 10 + ((130*(300/(SWIDTH - 20))) * i), SWIDTH - 20 , 120*(300/(SWIDTH - 20))) BgImg:[imgArray objectAtIndex:i] title:[imgArray objectAtIndex:i] selector:@selector(buttonClick:) Tag:10+i];
        [self.mainView addSubview:button];
    }
    // Do any additional setup after loading the view.
}
-(void)buttonClick:(UIButton *)sender{
    //TODO:按钮点击跳转
    BoardViewController *boardVC = [[BoardViewController alloc]init];
    if (sender.tag == 11) {
        boardVC.title = @"门板";
        boardVC.type = 1;
    }else if (sender.tag == 12){
        boardVC.title = @"装饰纸";
        boardVC.type = 2;
    }else{
        boardVC.title = @"板材";
        boardVC.type = 0;
    }
    boardVC.viewUrl = SUPPLYLIST;
    boardVC.viewtype = 0;
    [self.navigationController pushViewController:boardVC animated:YES];
}
-(UIButton *)createButtonImg:(CGRect)frame
                 BgImg:(NSString *)bgImg
                 title:(NSString *)title
              selector:(SEL)selector
                   Tag:(NSInteger)tag{
    UIButton *button = [self createButtonFrame:frame title:nil viewController:self selector:selector tag:tag];
    [button setBackgroundImage:[UIImage imageNamed:bgImg] forState:UIControlStateNormal];
    UIImageView *imageView = [self createImageViewFrame:CGRectMake((frame.size.width - 70)/2, (frame.size.height - 30)/2, 70, 30) image:nil imageName:@"货源标识" tag:0];
    [button addSubview:imageView];
    UILabel *titleLab = [self createLabelFrame:CGRectMake(0, 0, 70, 30) title:title titleColor:[UIColor whiteColor] tag:0];
    titleLab.textAlignment = NSTextAlignmentCenter;
    titleLab.font = [UIFont systemFontOfSize:12];
    [imageView addSubview:titleLab];
    return button;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
